﻿using System;
using System.Collections.Generic;
using System.Data;
using Module.Common.Models;
using Module.Core.DAO;
using Module.Core.EntitiesInfo;

namespace Module.Core.BusinessLogic
{
    public class CommentProductsBL
    {
        /// <summary>
        /// Saves a record to the CommentProducts table.
        /// </summary>
        public static int Insert(CommentProductsInfo commentProductsInfo)
        {
            try
            {
                return new CommentProductsDAO().Insert(commentProductsInfo);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        /// <summary>
        /// Saves a record to the CommentProducts table.
        /// </summary>
        public static void Update(CommentProductsInfo commentProductsInfo)
        {
            try
            {
                new CommentProductsDAO().Update(commentProductsInfo);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        /// <summary>
        /// Delete a record from the CommentProducts table.
        /// </summary>
        public static void Delete(int id)
        {
            try
            {
                new CommentProductsDAO().Delete(id);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        // <summary>
        // Selects a single record from the Products table.
        // </summary>
        public static CommentProductsInfo Select(int id)
        {
            try
            {
                return new CommentProductsDAO().Select(id);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        /// <summary>
        /// Selects all records from the CommentProducts table.
        /// </summary>
        public static CHRTList<CommentProductsInfo> SelectAll()
        {
            try
            {
                return new CommentProductsDAO().SelectAll();
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        /// <summary>
        /// Lấy tổng số bản ghi
        /// </summary>        
        /// <param name="isTotalRow">=True lấy tổng sổ bản ghi</param>
        /// <returns></returns>
        public static int SelectCount(int status,int productId, string starDatetime, string endDatetime)
        {
            try
            {
                return new CommentProductsDAO().SelectCount(status,productId, starDatetime, endDatetime);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        /// <summary>
        ///Lấy tổng số bản ghi trong bảng NewEmails
        /// </summary>
        public static int GetCount(int status)
        {
            try
            {
                return new CommentProductsDAO().GetCount(status);
            }
            catch (Exception)
            {

                throw;
            }
        }

        public static DataTable Search(int status,int productId, string starDatetime, string endDatetime, int beginRow, int endRow, string orderByColumn)
        {
            try
            {
                return new CommentProductsDAO().Search(status, productId,  starDatetime,  endDatetime,beginRow, endRow, orderByColumn);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        //Danh sách bình khi search
        public static DataSet ListCommentProductsPage(int status, DateTime createOnFrom, DateTime createOnTo, int currPage, int recodperPage, int pageSize, int total, string link)
        {
            try
            {
                DataSet ds = new DataSet();

                ds = new CommentProductsDAO().ListCommentProductsPage(status, createOnFrom, createOnTo, currPage, recodperPage, pageSize, total, link);
                if (ds != null)
                    return ds;
                return null;
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        //Bind du lieu vao droplist
        public static DataSet BindDropdownlist(int id)
        {
            try
            {
                DataSet ds = new DataSet();

                ds = new CommentProductsDAO().BindDropdownlist(id);
                if (ds != null)
                    return ds;
                return null;
            }
            catch (Exception ex)
            {
                throw;
            }

        }
        //Update lại trạng thái Status=0 -Bài bình luận về sản phẩm đang chờ duyệt
        //Status=1 -Bài bình luận về sản phẩm đc duyệt và đưa lên web
        public static void UpdateStatus(int id, int status)
        {
            try
            {
                new CommentProductsDAO().UpdateStatus(id, status);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

    }
}
